/*
 * create_process_apprach_two.cpp
 *
 *  Created on: Jan 14, 2009
 *      Author: tandaica0612
 */
#include <stdlib.h>
#include <iostream>
using namespace std;

int main(){
	pid_t child_id;
	cout << "The main process id is : " << getpid() << endl;
	child_id = fork();
	//
	//Trong lenh. if duoi' day :
	//	lenh. trong menh. de` if se~ duoc. thuc. thi tai. process cha
	//	lenh. trong menh. de` else se~ duoc. thuc. thi tai. process con
	if(child_id != 0){
		cout << "This is the parent process : " << getpid() << endl;
		cout << "And the child process id of it is : " << child_id << endl;
	}else{
		cout << "This is the child process : " << getpid() << endl;
	}
	//Neu' lenh. ko nam` trong lenh. if thi` ca? process cha va` process con se~ thuc. hien. lenh.
	cout << "This is command both parent and child process excutive" << endl;
	return 0;
}
/*
The main process id is : 7892
This is the child process : 7894
This is command both parent and child process excutive
This is the parent process : 7892
And the child process id of it is : 7894
This is command both parent and child process excutive
*/
